/**
 *Project: jh-framework
 *File: cn.xkshow.util.BeanHelper.java 
 *Author: admin@xkshow.cn with the copyrite
 ****************************************************************
 *   VERSION       DATE            BY       CHANGE/COMMENT
 * --------------------------------------------------------------
 *    1.0        2013-1-27        xkshow.cn         create
 ****************************************************************
 *note:
 ***************************************************************/ 
package cn.xkshow.framework.util;

import javax.servlet.ServletContext;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

public final class BeanHelper
{
  private static ApplicationContext ctx = null;

  public static void initContext(ServletContext servletContext)
  {
    if (ctx == null)
    {
      ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
    }
  }

  public static Object getBean(String name)
  {
    return ctx.getBean(name);
  }
}
